package top.heliming.youyou.cart.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.heliming.youyou.cart.config.JwtProperties;
import top.heliming.youyou.cart.interceptor.LoginInterceptor;

/**
 * description: //过滤器
 *
 * @author: heliming
 * @date:2019/06/14 下午 10:15
 */
@Configuration
@EnableConfigurationProperties(JwtProperties.class)
public class MvcConfig implements WebMvcConfigurer {

  @Autowired
  private JwtProperties jwtProperties;

  @Bean
  public LoginInterceptor loginInterceptor() {
    return new LoginInterceptor(jwtProperties);
  }

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(loginInterceptor()).addPathPatterns("/**");
  }
}
